From 07c76dc1749cd42f6c7cf8402723943e75410d03 Mon Sep 17 00:00:00 2001 From: "kaf24@labyrinth.cl.cam.ac.uk" Date: Mon, 3 Feb 2003 17:06:25 +0000 Subject: [PATCH] bitkeeper revision 1.22.1.2 (3e3ea191XZbqn2wImmnYu75uh_kNuQ) mm.h, hypervisor-if.h, memory.c, domain.c: Added update interface for the MPT. DOM0 no longer has direct write privileges. --- xen-2.4.16/common/domain.c | 3 --- xen-2.4.16/common/memory.c | 22 ++++++++++--------- .../include/hypervisor-ifs/hypervisor-if.h | 5 +++-- xen-2.4.16/include/xeno/mm.h | 8 +++++++ 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/xen-2.4.16/common/domain.c b/xen-2.4.16/common/domain.c index b6279f52fe..e1ae666f62 100644 --- a/xen-2.4.16/common/domain.c +++ b/xen-2.4.16/common/domain.c @@ -625,9 +625,6 @@ int setup_guestos(struct task_struct *p, dom0_newdomain_t *params) memset(l2tab, 0, DOMAIN_ENTRIES_PER_L2_PAGETABLE*sizeof(l2_pgentry_t)); p->mm.pagetable = mk_pagetable(phys_l2tab); - /* Domain 0 gets WRITE access to the read-only machine->physical table. */ - mk_l2_writeable(l2tab + (READONLY_MPT_VIRT_START >> L2_PAGETABLE_SHIFT)); - /* * NB. The upper limit on this loop does one extra page + pages for frame * table. This is to make sure a pte exists when we want to map the diff --git a/xen-2.4.16/common/memory.c b/xen-2.4.16/common/memory.c index ec11ec6e5d..03fa29a2e0 100644 --- a/xen-2.4.16/common/memory.c +++ b/xen-2.4.16/common/memory.c @@ -364,12 +364,6 @@ static int get_l2_table(unsigned long page_nr) DOMAIN_ENTRIES_PER_L2_PAGETABLE] = mk_l2_pgentry(__pa(current->mm.perdomain_pt) | __PAGE_HYPERVISOR); - /* - * DOM0 has the MPT mapped as WRITABLE. - * 'p_l2_entry' happens to be pointing at the right place at this point :-) - */ - if ( current->domain == 0 ) mk_l2_writeable(p_l2_entry); - out: unmap_domain_mem(p_l2_entry); return ret; @@ -703,9 +697,11 @@ static int do_extended_command(unsigned long ptr, unsigned long val) return err; } -/* functions to handle page table updates: upper half is invoked in case pt updates - * are requested by a domain and it invokes copy_from_user. bottom half is invoked - * both in case of domain downcall and domain building by hypervisor. +/* + * functions to handle page table updates: upper half is invoked in case pt + * updates are requested by a domain and it invokes copy_from_user. bottom half + * is invoked both in case of domain downcall and domain building by + * hypervisor. */ page_update_request_t * do_process_page_updates_uh(page_update_request_t *updates, int count) @@ -742,7 +738,6 @@ int do_process_page_updates_bh(page_update_request_t * cur, int count) /* Least significant bits of 'ptr' demux the operation type. */ switch ( cur->ptr & (sizeof(l1_pgentry_t)-1) ) { - /* * PGREQ_NORMAL: Normal update to any level of page table. */ @@ -765,7 +760,14 @@ int do_process_page_updates_bh(page_update_request_t * cur, int count) break; } } + break; + case PGREQ_MPT_UPDATE: + page = frame_table + pfn; + if ( DOMAIN_OKAY(page->flags) ) + { + machine_to_phys_mapping[pfn] = cur->val; + } break; /* diff --git a/xen-2.4.16/include/hypervisor-ifs/hypervisor-if.h b/xen-2.4.16/include/hypervisor-ifs/hypervisor-if.h index 6052c7b698..96826f5afd 100644 --- a/xen-2.4.16/include/hypervisor-ifs/hypervisor-if.h +++ b/xen-2.4.16/include/hypervisor-ifs/hypervisor-if.h @@ -36,8 +36,8 @@ typedef struct */ /* A normal page-table update request. */ #define PGREQ_NORMAL 0 -/* Make an unchecked update to a base-level pte. */ -#define PGREQ_UNCHECKED_UPDATE 1 +/* Update an entry in the machine->physical mapping table. */ +#define PGREQ_MPT_UPDATE 1 /* An extended command. */ #define PGREQ_EXTENDED_COMMAND 2 unsigned long ptr, val; /* *ptr = val */ @@ -50,6 +50,7 @@ typedef struct #define PGEXT_NEW_BASEPTR 5 #define PGEXT_TLB_FLUSH 6 #define PGEXT_INVLPG 7 +#define PGEXT_ #define PGEXT_CMD_MASK 255 #define PGEXT_CMD_SHIFT 8 } page_update_request_t; diff --git a/xen-2.4.16/include/xeno/mm.h b/xen-2.4.16/include/xeno/mm.h index 30071e76cf..e60ca748ad 100644 --- a/xen-2.4.16/include/xeno/mm.h +++ b/xen-2.4.16/include/xeno/mm.h @@ -114,6 +114,14 @@ extern unsigned int free_pfns; extern unsigned long max_page; void init_frametable(unsigned long nr_pages); +/* + * The MPT (machine->physical mapping table) is an array of word-sized + * values, indexed on machine frame number. It is expected that guest OSes + * will use it to store a "physical" frame number to give the appearance of + * contiguous (or near contiguous) physical memory. + */ +#define machine_to_phys_mapping ((unsigned long *)RDWR_MPT_VIRT_START) + /* Part of the domain API. */ int do_process_page_updates(page_update_request_t *updates, int count); -- 2.30.2